﻿using System;
using System.Linq;
using System.Transactions;
using NUnit.Framework;
using ProjetoComperio.BusinessLogicLayer;
using ProjetoComperio.DataLayer.Entities;

namespace ProjetoComperio.Test.BusinessLogicLayer
{
    [TestFixture]
    public class AcademicPersonBLLTest
    {
        AcademicPersonBLL academicPersonBLL;
        [TestFixtureSetUp]
        public void SetUp()
        {
            academicPersonBLL = new AcademicPersonBLL(); 
        }

        public void TestRetrieveContributionAcademicPeople()
        {

        }

        [Test]
        public void TestRegisterAcademicPersonInContribution_NullValues()
        {
            Assert.IsFalse(academicPersonBLL.RegisterAcademicPersonInContribution(0, 0));
        }

        [Test]
        public void TestRegisterAcademicPersonInContribution_NonExistentContribution()
        {
            Contribution nonExistentOne = new Contribution();
            nonExistentOne.ContributionID = 99999;

            Assert.IsFalse(academicPersonBLL.RegisterAcademicPersonInContribution(nonExistentOne.ContributionID, 0));
        }

        [Test]
        public void TestRegisterAcademicPersonInContribution_Valid()
        {
            using (TransactionScope transactionScope = new TransactionScope())
            {
                EventBLL eventBLL = new EventBLL();
                var eventToTest = new Event();
                eventToTest.Author = "Higor";
                eventToTest.AuthorDescription = "...";
                eventToTest.Description = "..";
                eventToTest.Details = "..";

                eventToTest.EndDate = DateTime.UtcNow.AddDays(1);
                eventToTest.StartDate = DateTime.UtcNow;
                eventToTest.Location = "...";
                eventToTest.RegisterDate = DateTime.UtcNow;
                eventToTest.SourceInfo = "...";
                eventToTest.Subject = "...";
                eventToTest.Title = "...";

                var studentBLL = new StudentBLL();
                var fakeStudent = StudentBLLTest.CreateFakeStudent();

                Assert.True(studentBLL.Create(fakeStudent, StudentBLLTest.UserName, "ajhajha*&12"));
                    
                //eventToTest.AcademicPerson = fakeStudent;

                //eventBLL.Create(eventToTest);

                //Assert.True(new AcademicPersonBLL().RegisterAcademicPersonInContribution(eventToTest.ContributionID, fakeStudent.PersonID));
            }
        }
    }
}
